Enter if Low[bar-1]<Low[bar] and Close[bar]>Close[bar-1]
Author: brucolaco
Creation Date: 5/8/2020 6:57 PM
profile picture

brucolaco

#1
Hello,

I'm starting to use the program now and I'm a little confused. I will describe an example of the rule that I would like to create to see if it can be created.

Example:
CANDLE Day 1
Aperture: 17.07
Maximum: 17.36
Minimum: 15.64
Closing: 16.47

CANDLE Day 2 (alarm)
Aperture: 16.13
Maximum: 20.41
Minimum: 14.94
Closing: 19.55

NOTE 1:
Enabled alarm due to:
Minimum day 2 (14.94) <Minimum day 1 (15.64)
Closing day 2 (19.55)> Closing day 1 (16.47)

NOTE 2: This day is what the strategy will count as D day for entry. To work, the entry must be UP to 2 days after that.


CANDLE Day 3 (entrance)
Aperture: 19.60
Maximum: 19.79
Minimum: 19.45
Closing: 19.65

NOTE: I enter the trade, as the entry is 1 cent above the maximum of day 2, that is, 20.42

----------
GAIN
The output looks like this:
The difference difference between the maximum and minimum of the candle on the day of the alarm (Day 2)
20.41 - 14.94 = 5.47
Now I take 61.8% of 5.47 that gives: 3.38
We add this value to the entry price (20.42), that is, I will leave when the stock reaches 23.8 (20.42 + 3.38)

------------
STOP LOSS
The Stop is when the action reaches the low of the candle on day 2 (14.94)

--------------

Can I set up this setup in the program?
profile picture

Eugene

#2
If I understood you correctly, you enter when:

1. Low[bar-1] < Low[bar]
2. Close[bar] > Close[bar-1]
3. High[bar] > High[bar - 1]

Then you have to set the Rules like this:



1. Buy at stop channel high - choose "High" and "1"
2. Choose Low/Low for the "<= Lowest" rule
3. And Close/Close for the ">= Highest" rule

For the stop loss there is no matching condition. But of course it'd be a piece of cake to get it done in Strategy code if you're interested.
profile picture

Cone

#3
Welcome brucolaco

CODE:
Please log in to see this code.
profile picture

brucolaco

#4
Thanks @Eugene, but I had tried it and I couldn't.

@Cone,
I put your code here to run and saw that the entry is not going to the right place. I was trying to build one based on a code I got and I was having the same problem. Look at this example:


03/18 - Candle 1
Low: 16.00
Close: 16.85

03/19 - Candle 2:
Low: 15.29
Close: 20.00
High: 20.88

Rule ok: 15.29 <16.00 and 20.00> 16.85

Admission price: 20.88 + 0.01 = 20.89


The script generated the purchase at 21.65 and not 20.89.

Can you correct this entry?
profile picture

Cone

#5
All of these are examples with gap openings. The trigger price is correctly calculated but since we programmed a Stop order, it is executed "at Market" because the market opened above the trigger price.

In this case where the market opens above the trigger price, we can issue a limit order - but not apriori. For end-of-day trading (daily bars), you'd have to check the open first before placing the order. What happens if it opens only 1 penny higher? and the next tick (only one) is at the trigger price and then it trades higher the rest of the day? Are you willing to miss that trade? TWLO is a good example not to miss from Thursday.
profile picture

Cone

#6
Here's a modification for you, but please read the comments.

Important!

This script is for End of Day only.

CODE:
Please log in to see this code.
profile picture

brucolaco

#7
Understand.

Thank you my friend !
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).