I am NOT a professional coder. I'm not even a good coder at that. I've only started Pine Script coding since September 2019. I am teaching myself.
This script is far from finished. I need to tweak a number of things about this script. Namely:
Add a validity window to the 'trigger bar' condition. Ie , I want to shut down the condition when the price closes above EMA21
Change the order entry so they are stop orders, using the stop entry price derived from the signals
Make changes to lot sizing
Add a trailing stop condition
Comments welcome, but do not expect me to reply to any questions or requests. In fact, don't expect any replies from me. I consider myself notoriously bad at replies.
I do welcome any feedback from any seasoned coders out there, as I am still a novice coder, and have so much to learn!
As to anyone who wants to criticise me - constructive and helpful criticism are most welcome, criticism to make yourself feel superior to me - you kind can eat a dk .
For the strategy rules, google the user ForexSignals TV account and look for the video "SIMPLE and PROFITABLE Forex Scalping Strategy".
Share, learn, prosper
Peace to y'all
included a validity window for the signals
added a position sizing script, based on % equity risked per trade
cleaned up the script
more improvements needed before I consider it finished are:
1. Refine how the SL and TP lines are plotted. I want them to only plot inside a trade. This would make it visually appealing to review the start and finish of a trade, and to look at the SL and TP and entry price of that trade
2. Figure out how to pyramid trades. Ie, enter into another valid signal whilst there is an open trade.
3. I notice that the SL and TP levels change as subsequent signal bars are detected after a trade is under way. This has the effect of unstabilizing the SL and TP levels. Hence I can't fully trust the back test results as the trade is not behaving the way i want it to
4. Figure out a trailing stop method. ie figure out a criteria for the TS, and to combine it with a revised exit method. (see below).
5. Figure out how to partially exit the position as the trade goes my way. the original forexsignalsTV exit rules are - exit 1/2 of the position upon reaching 1R, then move SL to Break Even. Ie, the first TP of the first 1/2 is at 1R, whereas the TP of the second 1/2 of the position is either 2R, or a trailing stop according to point 4.
Anyone with tips on improving this script, please feel free to comment
share, learn, and earn
I would have liked to set up alerts when a trade is active, but Tradingview doesn't allow alerts from a strategy and must be done from a study.
The only last improvement would be in tweaking the order management side of the script - where there is an option to dynamically change the SL level to break even once TP1 is reached. And to add a trailing TP for TP2.
I would like to ride a trend beyond a 2R, once I lock in a 1R return. As they say - ride the winners and cut the losers.
I think however I will give this strategy a rest and move onto the next project!
It's been fun to complete my first script, from start to finish - two weeks spent to complete it.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.