5min_rsi_qual_02EXP

Author: Ron Thompson
Price Data Components
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategyIt automatically opens orders when conditions are reached
Indicators Used
Relative strength index
0 Views
0 Downloads
0 Favorites

Profitability Reports

GBP/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
5min_rsi_qual_02EXP
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//+ Trade on qualified RSI                                           |
//+------------------------------------------------------------------+


#property copyright "Ron Thompson"
#property link      "http://www.lightpatch.com/forex"

// User Input
extern double Lots = 0.1;
extern double Stop_Loss = 21;


//+------------------------------------------------------------------+
//| What to do 1st                                                   |
//+------------------------------------------------------------------+

int init ()
  {
   return(0);
  }



//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int deinit()
  {
   return(0);
  }



//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   double total;
   int cnt, i;
   bool foundorder=false;
   double rsi=0;
   
   
   bool last11=false;
   bool last22=false;
   
   double nslB=0,nslS=0,osl=0,ccl=0;
   
   //
   // Error checking
   //
   
   if(Bars<100)
     {
      Print("bars less than 100");
      return(0);
     }
   
   if(AccountFreeMargin()<(1000*Lots))
     {
      Print("We have no money");
      return(0);
     }

   //
   // only one order at a time/per symbol 
   // so see if our symbol has an order open
   //
   total=OrdersTotal();
   for(cnt=0;cnt<OrdersTotal();cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderSymbol()==Symbol())
        {

         // An order for this Symbol() is open so check
         // the stoploss, adjust as price changes
         // in the favorable direction.

         ccl=Close[1]; // 1 NOT 0 or the swings will kill ya!
         osl=OrderStopLoss();
         nslB=ccl-(Stop_Loss*Point());
         nslS=ccl+(Stop_Loss*Point());

         // Existing BUY orders trailing stop
         if ( OrderType() == 0 )
           {
            if ( nslB > osl )
              {
               Print  ("BUY MODIFY ",Symbol()," osl=",osl," nsl=",nslB);
               Comment("BUY MODIFY ",Symbol()," osl=",osl," nsl=",nslB );
               OrderModify(OrderTicket(),OrderOpenPrice(),nslB,OrderTakeProfit(),0,Red);
              }
           }

         // Existing SELL orders trailing stop
         if ( OrderType() == 1 )
           {
            if ( nslS < osl )
              {
               Print  ("SELL MODIFY ",Symbol()," osl=",osl," nsl=",nslS );
               Comment("SELL MODIFY ",Symbol()," osl=",osl," nsl=",nslS );
               OrderModify(OrderTicket(),OrderOpenPrice(),nslS,OrderTakeProfit(),0,Red);
              }
           }

         // set the 'found' flag so we don't buy/sell any more
         foundorder=true;
         break;
        }
     }

   if ( foundorder == false )
     {

      Comment(" ");

      rsi=iRSI(Symbol(),0,28,PRICE_CLOSE,1);
      
      if (rsi>=55)
        {
         last11=true;
         for(i=1; i<=11; i++)
           {
            if (iRSI(Symbol(),0,28,PRICE_CLOSE,i)<55) last11=false;
           }

         last22=true;
         for(i=1; i<=22; i++)
           {
            if (iRSI(Symbol(),0,28,PRICE_CLOSE,i)<55) last22=false;
           }

         if (last11==true && last22==false) 
           {
            // it seems backwards, but it's because qualified RSI turns
            // out to be a top or bottom indicator much more often than
            // it turns out to be a trend indicator.
            Print("SELL Order started  ",Bid);
            OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+(11*Point()),0,"11RSI Sell",16321,0,Red);
            if(GetLastError()==0)Comment("SELL Order opened : ",Bid );
           }
        }


      if (rsi<=45)
        {
         last11=true;
         for(i=1; i<=11; i++)
           {
            if (iRSI(Symbol(),0,28,PRICE_CLOSE,i)>45) last11=false;
           }

         last22=true;
         for(i=1; i<=22; i++)
           {
            if (iRSI(Symbol(),0,28,PRICE_CLOSE,i)>45) last22=false;
           }

         if (last11==true && last22==false) 
           {
            // it seems backwards, but it's because qualified RSI turns
            // out to be a top or bottom indicator much more often than
            // it turns out to be a trend indicator.
            Print("BUY  Order started  ",Ask);
            OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-(11*Point()),0,"11RSI Buy",16123,0,White);
            if(GetLastError()==0)Comment("BUY Order opened : ",Ask);
           }
        }
     }           

   return(0);
  }

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---