Hey fellow traders!
I’m reaching out to share an idea that’s been bouncing around in my head for a while now. It’s based on the conservative intraday scalping strategy, but I hit a bit of a snag trying to find a fitting indicator in MetaTrader 4 (MT4).
After some digging, I stumbled upon the Center of Gravity.mq4 indicator. My goal is to hook it up to an EA, but so far, it’s been a tough nut to crack. The EA won’t open any trades—neither in demo nor during backtesting. So, I’m left wondering: what’s the deal?
Here’s the idea in a nutshell: this indicator creates five lines that run parallel to the trend. My plan is to open trades where these extreme lines intersect. Ideally, I’d like to implement a trailing stop as well. The thought is that when a moving average (SMA with a period of 1) based on the LOW prices crosses the lower line of the indicator from below, that would signal a buy. Conversely, a cross from above for the SMA based on HIGH prices would signal a sell. The potential for further development is endless, but I need to tackle this core issue first.
Indicator: Center of Gravity.mq4
Expert Advisor: C_S_intraday.mq4 (this is a basic version without deposit control, timeframe settings, or trailing stops)

Bitmap
//+---------------------------------------------------------------------+ //| C_S_intraday.mq4 | //| | //+---------------------------------------------------------------------+ // // // extern double lots=0.1; //extern int StopLoss=30 ; //extern int TrailingStop=15; //extern int Slippage=2; extern int BB = 125; extern int MM = 2; extern int II = 0; extern double KK = 2.0; extern int NN = 1102; double maH0,maH1,maL0,maL1; //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { maH0=iMA(NULL,0,1,0,MODE_LWMA,PRICE_HIGH,0); //moving average based on high maH1=iMA(NULL,0,1,0,MODE_LWMA,PRICE_HIGH,1); //moving average based on high maL0=iMA(NULL,0,1,0,MODE_LWMA,PRICE_LOW,0); //moving average based on low maL1=iMA(NULL,0,1,0,MODE_LWMA,PRICE_LOW,1); //moving average based on low int B= BB; // int M= MM; // int I= II; // double K= KK; // int N= NN; // double cgh = iCustom(NULL,0,"Center of Gravity",B,M,I,K,N,3,0); double cgl = iCustom(NULL,0,"Center of Gravity",B,M,I,K,N,4,0); if (cgl<maL0) //if moving average (low) crosses the lowest line of the indicator from below { OrderSend(NULL,OP_BUY,lots,Ask,2,Ask-10*Point,Ask+20*Point,"create1",123,0,Lime); } /* if (cgh>maH0) { OrderSend(NULL,OP_SELL,lots,Bid,2,Bid+10*Point,Bid-20*Point,"create1",123,0,Red); } */ //---- return(0); } //+------------------------------------------------------------------+
Comments 0