Hello I would like to write this code if someone can help me I would be very grateful
I will buy the asset at the opening of each candle if its price changes by 70%. take profit yes +0.5%. stop-loss -0.5
I will sell the asset at the opening of each candle if its price changes by 70%. Take profit -0.5%. Stop-loss +0.5%.
Time unit 15min. Thank you for your understanding.
JSParticipant
Senior
Hi @Dovakin
Do you mean a price change of 70% in 15 minutes?
JSParticipant
Senior
DefParam CumulateOrders = False
If Close / Close[1] > 1.01 then
Buy 1 contract at market
ElsIf Close / Close[1] < 0.99 then
SellShort 1 contract at market
EndIf
Set Target %Profit 1
Set Stop %Loss 0.8
You can adjust everything yourself:
- Number of contracts
- % stop loss
- % take profit
- Tijdframe
- Index
- …
Thank you very much but I have entered the code but nothing is displayed no matter what period I choose
JSParticipant
Senior
Hi
@Dovakin
Did you BackTest the code?
I don’t know if I expressed myself badly but this is exactly what I want
each candle has an opening i want to take position from that opening. then i want to multiply that opening by 1%. and exit that candle if i am right with a 0.6% gain. if i am wrong i take a 0.3% loss. i am sorry i am a novice.
JSParticipant
Senior
At the opening of a candle what kind of position do you want to take (Long or Short) and under what conditions do you want to go Long or Short?
I don’t understand what you mean by “multiply the opening by 1%”…
For example this candle of March 16, 22 of the ndx 100 at 20:00 the opening is 13738.2. In the framework of a long position, if the asset gains 1%, I take 13738.2 and multiply by 1%. That gives me 13875.582. If I reach 13875.582 I take a buy position. If from 13875.582 I gain 0.4% I exit my buy position with a gain. In case I reach 13875.582 and I have a drop of 0.4% I exit my buy position with a loss. And I do this for each candle on a time unit of 1 hour.
In the case of a short position like this 26th of April at 3pm of the ndx 100. The opening is 13477.7. If the asset loses 1%. I take the opening which is 13477.7 which I multiple by 1%. That makes 13342.99. And then I take a sell position. If from 13342.99 I gain 0.4% I exit my sell position with my gain. If on the contrary the price goes up I exit at 0.4% with a loss. And this for each candle on a time unit of 1 hour
JSParticipant
Senior
Hi
@Dovakin
DefParam CumulateOrders = False
If OnMarket[1] and Not OnMarket then
OpenPrice = Open
EndIf
If Close > OpenPrice * 1.01 then
Buy 1 contract at market
ElsIf Close < OpenPrice * 0.99 then
SellShort 1 contract at market
EndIf
Set Target %Profit 0.4
Set Stop %Loss 0.4
thank you Mr JS.
<span class="Y2IQFc" lang="en">just one thing if we take this trade from April 25 at 4 p.m. it's the same for the others.</span>
Entry is 13384,015 NOT ONLY 13251,5. BECAUSE I TAKE POSITON WHEN<span class=”Apple-converted-space”> </span>I HAVE OPEN*1% like here 13251,5*0,01 equal 13251,5+132,52 equal 13384,015.<span class=”Apple-converted-space”> </span>IF I HAVE 0,4% OF PROFIT I CLOSE MY POSITION LIKE 13384,015*0,4% EQUAL 13384,015+53,55 equal<span class=”Apple-converted-space”> </span>134737,55 , I close my position with profit. But if I have 13384,015*0,4 equal 13384,015-53,55 equal 13330,47 I close my position with loss.
just one thing
if we take this trade from April
25 at 4 p.m. it’s the same
for the others.
Entry is 13384,015 not only 13251,5. Because I take position when I have open*1% like here 13251,5*0,01 equal 13251,5+132,52 equal 13384,015.
If I have 0,4% of profit I close my position like 13384,015*0,4% EQUAL 13384,015+53,55 equal 134737,55 , I close my position with profit. But if I have 13384,015*0,4 equal 13384,015-53,55 equal 13330,47 I close my position with loss.