Hi,
I'm stuck with this problem:
I would like to apply a signal for the entry and a signal for the exit into a chart and to start autotrade.
But I would like to have only 1 entry and only 1 exit, not continuous autotrading.
I tried creating some flags to stop signal trading but with no luck.
Has anyone solved this feature and has any code to share ?
Thanks in advance.
Massimo
How can I autotrade with a signal only for one entry/exit ? [SOLVED]
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: How can I autotrade with a signal only for one entry/exi
Please post your flag, we can work from there.Hi,
I'm stuck with this problem:
I would like to apply a signal for the entry and a signal for the exit into a chart and to start autotrade.
But I would like to have only 1 entry and only 1 exit, not continuous autotrading.
I tried creating some flags to stop signal trading but with no luck.
Has anyone solved this feature and has any code to share ?
Thanks in advance.
Massimo
Re: How can I autotrade with a signal only for one entry/exi
This solution should work, I'll test it on monday.
Regards
Massimo
Code: Select all
inputs: LECondition( C > highest(high,20)[1] ) ;
vars: flag(1);
if LastBarOnChart then once flag=0;
if LECondition and flag=0 then begin
Buy ( "LE_Flag=0" ) next bar at market ;
flag=1;
End;
print(flag:0:0," - ", BarNumber:0:0);
Massimo
Last edited by maxmax68 on 29 Mar 2015, edited 1 time in total.
Re: How can I autotrade with a signal only for one entry/exi
You could use a conditional with positionprofit, so once a trade is taken and exited whether you have a win or loss, there would be a positionprofit. So you could put one of your first lines of code to be
"If PositionProfit <>0 Then Begin;"
Only problem is if you are flat on that first trade then it would allow another entry.
"If PositionProfit <>0 Then Begin;"
Only problem is if you are flat on that first trade then it would allow another entry.
Re: How can I autotrade with a signal only for one entry/exi
you might look at EntriesToday(Date) = 0 , which will limit your entries each time you turn strategy automation off to on, such as below:
Code: Select all
If LastBarOnChart and EntriesToday(Date) = 0 and Buy_Condition
then
Buy Size_Entry Contracts Next Bar Your_Price LIMIT ;
Re: How can I autotrade with a signal only for one entry/exi
Thanks escamillo,
I was not aware of this function.
To work the counting of entries should reset every time you start the signal.
I'll try it as soon as possible.
Regards
Massimo
I was not aware of this function.
To work the counting of entries should reset every time you start the signal.
I'll try it as soon as possible.
Regards
Massimo
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: How can I autotrade with a signal only for one entry/exi
You can go to the Wiki and get yourself acquainted with these keyword categories:
Strategy Orders (28)
Strategy Performance (33)
Strategy Position (47)
Strategy Position Synchronization (2)
Strategy Position Trades (29)
Strategy Properties (4)
Strategy Orders (28)
Strategy Performance (33)
Strategy Position (47)
Strategy Position Synchronization (2)
Strategy Position Trades (29)
Strategy Properties (4)
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: How can I autotrade with a signal only for one entry/exi
You don't need to use function...TJ,
thanks for yours always precious answers.
I did my homeworks.
Probably you intended functions of Powerlanguage and not Wiki.
Best regards
Massimo
try
EntryDate
eg.
Code: Select all
if EntryDate(1) <> Date then Begin... // ie. haven't done any trades today yet