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 reachedIt Closes Orders by itself
Indicators Used
Moving average indicator
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
44.00 %
Total Trades 1003
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -1.54
Gross Profit 1225.50
Gross Loss -2771.90
Total Net Profit -1546.40
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
48.00 %
Total Trades 1500
Won Trades 95
Lost trades 1405
Win Rate 0.06 %
Expected payoff -1.71
Gross Profit 2346.20
Gross Loss -4915.00
Total Net Profit -2568.80
-100%
-50%
0%
50%
100%
st_2
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//| 3MA Bunny Cross Expert                               |
//+------------------------------------------------------------------+
#property copyright "Ron Thompson"
#property link      "http://www.lightpatch.com/forex"

// User Input
extern double Lots = 0.1;
extern double stoploss = 250;
extern double MovingAvg = 40;




//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|

int init()
  {
   return(0);
  }


//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
  {
   double   cMA=0, pMA=0;
   double   p=Point();
      
   bool     found=false;
   bool    rising=false;
   bool   falling=false;
   bool    bought=false;
   bool      sold=false;
   bool oldenough=false;
   
   
   int      cnt=0;
   int      err=0;
   double   ccl=0;
   double   osl=0;
   double   nslB=0;
   double   nslS=0;
   

   // Error checking
   if(Bars<100)                        {Print("Bars less than 100"); return(0);}
   if(AccountFreeMargin()<(1000*Lots)) {Print("We have no money");   return(0);}

   // get all the moving averages at once
   cMA=iMA(Symbol(), 0, MovingAvg, 0, MODE_LWMA, PRICE_CLOSE, 1);
   pMA=iMA(Symbol(), 0, MovingAvg, 0, MODE_LWMA, PRICE_CLOSE, 2);

   // determine if FST line is rising or falling around SLO line
   if (pMA<=cMA) {rising=true;  falling=false;}
   if (pMA>=cMA) {rising=false; falling=true;}

   // Does the Symbol() have an open order
   for(cnt=0;cnt<OrdersTotal();cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderSymbol()==Symbol())
        {
         found=true;
         ccl=Close[1];  
         osl=OrderStopLoss();
         nslB=ccl-(stoploss*p);
         nslS=ccl+(stoploss*p);
         break;
        }
         else
        {
         found=false;
        }        
     }
   

   // trail stop (usr bar 1, NOT 0)
   if (found && OrderType()==0 && nslB > osl )
     {
      Print("BUY MODIFY! ",Symbol()," osl=",osl," ccl=",ccl," nslB=",nslB);
      OrderModify(OrderTicket(),OrderOpenPrice(),nslB,OrderTakeProfit(),0,Red);
     }

   // trail stop (usr bar 1, NOT 0)
   if (found && OrderType()==1 && nslS < osl )
     {
      Print("SELL MODIFY! ",Symbol()," osl=",osl," ccl=",ccl," nslS=",nslS );
      OrderModify(OrderTicket(),OrderOpenPrice(),nslS,OrderTakeProfit(),0,Red);
     }


   if (found==false && rising)
     {
      OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-(p*stoploss),0,"BC Buy",16123,0,White);
      //OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"BC Buy",16123,0,White);
      return(0);
     }

   if (found==false && falling)
     {
      OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+(p*stoploss),0,"BC Sell",16321,0,Red);
      //OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"BC Sell",16321,0,Red);
      return(0);
     }

   if (OrderType()==0) {bought=true;  sold=false;}
   if (OrderType()==1) {bought=false; sold=true;}

   // wrong direction, just print report
   if (rising && bought) {Print("Cross, but already Buy "); return(0);}
   if (falling && sold)  {Print("Cross, but already Sell"); return(0);}
     
   if (rising && sold)       //exist sell
     {
      Print(Symbol()," CLOSE sell order");
      OrderClose(OrderTicket(),Lots,Ask,0,Red);
     }
   if (falling && bought)  // exist buy
     {
      Print(Symbol()," CLOSE buy order");
      OrderClose(OrderTicket(),Lots,Bid,0,White);
     }

   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 ---