How do we analyse the next bar? - page 2

 

@gjol:: The function should scan all the bars as they are formed right?

But here the function is placing the orders during the current bar itself i.e. the bar during which the original order was opened.

I want it to wait and check the next bar and then place the order and keep on checking the bars to follow.

Is it possible.

Sorry for replying so late but was engrosed in watching the market dance!!!! ;)

 

(I knew it) this function is designed to take action only at a new bar opens it doesn't designed to wait for new bar +1

 

The renewed code works correctly.
Function "checkopen();" is invoked on each new bar only once.
But.
Inside the single function "checkopen();" there are 4 functions "OrderSend ()".
May be this is an essence of the strategy.
To prevent multiplying trade inside the single function "checkopen();", it is sufficient to add "return;" after each or desired "OrderSend ()".
Regards,
Airat

 
qjol:

designed to take action only at a new bar opens it doesn't designed to wait for new bar +1


@gjol:: Ok.

@Ais:: What if I place the new orders in another function,say "New()". Will it open the orders not in the same bar but different ones?

 
ksrohit2712:


@gjol:: Ok.

@Ais:: What if I place the new orders in another function,say "New()". Will it open the orders not in the same bar but different ones?


i don't understand what is your problem, simple add 1 bar shift @ the iCustom
 

I'm not able to understand what you want to say?

Can you elaborate a little?

I apologize for such questions that are irritating to you but I'm not a pro coder yet! But striving to be one...

 

just change your code to:

FMA=iMA(NULL,0,MPeriod1,0,MODE_SMA,PRICE_OPEN,1);
SMA=iMA(NULL,0,MPeriod2,0,MODE_SMA,PRICE_OPEN,1);
PFMA=iMA(NULL,0,MPeriod1,0,MODE_SMA,PRICE_OPEN,2);
PSMA=iMA(NULL,0,MPeriod2,0,MODE_SMA,PRICE_OPEN,2);

 

Ok ok.... How silly of me!!!!!!!!!!

So that's what you were saying! I thought you wanted me to introduce iCustom()...

I've already tried that. It opens and closes the orders late!

But thanks for taking out time to reply.

 
qjol:

just change your code to:

FMA=iMA(NULL,0,MPeriod1,0,MODE_SMA,PRICE_OPEN,1);
SMA=iMA(NULL,0,MPeriod2,0,MODE_SMA,PRICE_OPEN,1);
PFMA=iMA(NULL,0,MPeriod1,0,MODE_SMA,PRICE_OPEN,2);
PSMA=iMA(NULL,0,MPeriod2,0,MODE_SMA,PRICE_OPEN,2);


have u tried this code with the function

if(NewBar())
{
checkopen();
}

 

Yes I did try it.

What I want to do is:

At 1, it should open a BUY order.(Blue arrow is for SELL and Red for BUY) So that it'll be able to get the profit and vice versa for opposite condition.

I hope you are getting the picture.

.

Reason: