How to code? - page 12

 

Tradestation time filter code explanation help

Hi,

I am looking at a tradestation time filter code and since i never use tradestation before, i am not very sure about it. Anyone who has experienced with it can clarify it?

inputs:

time_offset(0), {EST Time}

begin_time(800),

end_time(1600);

if time >=begin_time + time_offset and time <=end_time + time_offset then begin

Is this time filter code saying trade will be initiated from 8.00 am - 4.00 pm EST time?

Thanks for helping.

 

The offset number of -100 is to be used when the data is in say Central Stand. You have to figure that one out.

As for the logic, it says if it is between 800 hrs and 1600 hrs, then begin to do something... like monitor for a certain set up.

Hope this helps.

Maji

 

Hi Maji,

Thanks for the confirmation and the offset comment. Now i know how to use the offset.

 

lot scaling question ..need code help..

I know that I am responsible for taking my own risks when using any strategy. I don't want to scare anyone. I'm looking for some help with a code that I could put in an EA which would adjust the lot size of orders according to a percentage of the current free margin in the account and let me choose what percentage of that to enter the next position with.

 

Hey-

Set an external double like:

extern double RiskFraction=0.1;

Then in the "start(" add:

double Lots=(MathRound(AccountFreeMargin()*RiskFraction/10.0)/100);

....

OrderSend(Symbol(),OP_BUY,Lots,Ask,0,0,0,"EA Name",MagicNum,0,Green);

.1 means risk 10% of your account.

Good luck ,

Gavner

 

Question

Gavner:
Hey-

Set an external double like:

extern double RiskFraction=0.1;

Then in the "start(" add:

double Lots=(MathRound(AccountFreeMargin()*RiskFraction/10.0)/100);

....

OrderSend(Symbol(),OP_BUY,Lots,Ask,0,0,0,"EA Name",MagicNum,0,Green);

.1 means risk 10% of your account.

Good luck ,

Gavner

This is what i was looking for, for my EA.

Also, is there a part of code which will limit how many trades will be opened based on the Avaliable Margin.

Example: It will continue to open trades until 50% of the available Margin balance is used?

Thanks!

Spider~

 

Need Coders to Break The Code

viktoriwan:
it goes something like this : if(mov(zig(4,c),4,e) - mov(zig(9,c),7,e)

Hello... anyone notice this thread and want to help me ?

 
 

Need Account triggered stop loss code..programmers wanted

I would like to use a stop loss that is triggered based on the account equity falling below the account balance by a specified percent. With one strategy something simple like ZERO percent should work ,but I'd like to be able to use this on other strategies too so I'd like to be able to specify a tolerance percentage of loss for each losing position this way. On triggering I would like it to close all open orders.

Could someone make this for me. I have a strategy that would really benefit from this. Trouble is that a traditional stop loss messes it up. If I can get the losers stopped out so they don't draw down the equity from the winners it should really rock and roll.

 

if(AccountEquity()<AccountBalance()) {

{

int ttotal = OrdersTotal();

for(int i=ttotal-1;i>=0;i--)

{

OrderSelect(i, SELECT_BY_POS);

int type = OrderType();

bool result = false;

switch(type)

{

//Close opened long positions

case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );

break;

//Close opened short positions

case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );

}

if(result == false)

{

Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );

Sleep(3000);

}

}

return(0);

}

}

}

ok this is what I tried ..it's mostly copied from another code someone else here made...but it's just closing everything as fast as they open and not paying any attention to the 'if' condition before executing closes....oy I'm not good at this....I obviously don't have the part that is doing the closing of orders sufficiently attached to the conditional line that compares the account equity to the account balance. Could someone please help me with this?