What am I doing wrong?

 

Could some kind soul please explain what is wrong with the following code.

1. It sort of works but does not update once chart is loaded

2. If I try to change timeframe on chart then the application hangs?

Any help appreciated.

My code.........

#property indicator_chart_window

double mR1, mS1;

int mH = 0, mL = 0;

extern int mPeriod = 3,

mHist = 100 ;

//-----------------------------------------------+

int init()

{

mR1 = High[0];

mS1 = Low[0];

return(0);

}

//-----------------------------------------------+

int start()

{

int counted_bars = IndicatorCounted();

int limit= MathMin(Bars, mHist) - counted_bars;

for(int i = limit; i > 0; i--)

{

if (High[i+mPeriod+1] >= High[iHighest(NULL,0,MODE_HIGH, mPeriod, i)]

&& High[i+mPeriod+1] >= High[iHighest(NULL,0,MODE_HIGH, mPeriod, i+mPeriod+2)] )

{

mH++;

mR1 = High[i+mPeriod+1];

// ObjectDelete("mRes");

ObjectCreate("mRes"+mH, OBJ_TREND, 0, Time[i+mPeriod+1], mR1, Time, mR1);
ObjectSet("mRes"+mH,OBJPROP_RAY, false);
ObjectSet("mRes"+mH, OBJPROP_WIDTH,1);
ObjectSet("mRes"+mH, OBJPROP_STYLE,0);
ObjectSet("mRes"+mH, OBJPROP_COLOR, Blue);
}

if (Low[i+mPeriod+1] <= Low[iLowest(NULL,0,MODE_LOW, mPeriod, i)]
&& Low[i+mPeriod+1] <= Low[iLowest(NULL,0,MODE_LOW, mPeriod, i+mPeriod+2)] )
{
mL++;
mS1 = Low[i+mPeriod+1];
//ObjectDelete("mRes");
ObjectCreate("mSupp"+mL, OBJ_TREND, 0, Time[i+mPeriod+1], mS1, Time, mS1);
ObjectSet("mSupp"+mL,OBJPROP_RAY, false);
ObjectSet("mSupp"+mL, OBJPROP_WIDTH,1);
ObjectSet("mSupp"+mL, OBJPROP_STYLE,0);
ObjectSet("mSupp"+mL, OBJPROP_COLOR, Red);
}
}
return(0);
}
//-----------------------------------------------+
int deinit()
{

for(int z = 1; z <= mH; z++)
{
ObjectDelete("mRes"+z);
}
for(int y = 1; z <= mL; y++)
{
ObjectDelete("mSupp");
}
return(0);
}

//-----------------------------------------------+

TIA

 

is that for GFT DealBook? if so, may be best posting that in the GFT coding forums Forex Trading Software - Online Currency Trading Software - Chart Studio® Forum

It doesnt look like MQL code, so if you are trying to load it into MetaEditor and your MT4 platform then you may have issues

 

Thanks for reply,

NO!

Def not for GFT

It is for MT4 but does not work as explained above

 

I like candle stick and Bollinger band for trading analysis and trend finding. It is not necessary to get right move of market all the time. I can be wrong with entry or choosing lot and risk management but it is a part of trading that tells you gradually about right things.

 

error is often experienced by traders. Especially when analysis trading . Many factors affect the trading analysis, especially market today is very difficult to predict. we should be able to learn from our mistakes. With evaluation we can learn from the mistakes of our trading.

Reason: