You are a professional PineScript version=5 developer. You know how to code indicators…
- User
You are a professional PineScript version=5 developer. You know how to code indicators and strategies and you also know their differences in code. I need your help to turn a TradingView indicator into a strategy please.
Respect these instructions:
-
Convert all Indicator specific code to Strategy specific code. Don't use any code that a TradingView Strategy won't support. Especially timeframes and gaps. Define those in code so they are semantically the same as before.
-
Preserve the timeframe logic if there is one. Fill gaps.
-
If the indicator is plotting something, the strategy code shall plot the same thing as well so the visuals are preserved.
-
Don't trigger a short. Simply go Long and Flat.
-
Always use 100% of capital.
-
Set commission to 0.1%.
-
Set slippage to 3.
-
strategy.commission.percent and strategy.slippage don't exist in PineScript. Please avoid this mistake. Set those variables in the strategy() function when initiating the strategy.
-
When initiating the strategy() function, don't use line breaks as this will cause a compiler error.
-
Leave all other strategy settings to default values (aka. don't set them at all).
-
Add Start Date and End Date inputs/filters so the user can choose from when to when to execute trades. Start with 1st January 2018 and go to 31st December 2069.
-
When setting the title of the strategy, add "Demo GPT - " at the start of the name and then continue with the name of the strategy.
This is the code of the Indicator you shall migrate to a TradingView Strategy: //Created by user ChrisMoody updated 4-10-2014 //Regular MACD Indicator with Histogram that plots 4 Colors Based on Direction Above and Below the Zero Line //Update allows Check Box Options, Show MacD & Signal Line, Show Change In color of MacD Line based on cross of Signal Line. //Show Dots at Cross of MacD and Signal Line, Histogram can show 4 colors or 1, Turn on and off Histogram. //Special Thanks to that incredible person in Tech Support whoem I won't say you r name so you don't get bombarded with emails //Note the feature Tech Support showed me on how to set the default timeframe of the indicator to the chart Timeframe, but also allow you to choose a different timeframe. //By the way I fully disclose that I completely STOLE the Dots at the MAcd Cross from "TheLark"
study(title="CM_MacD_Ult_MTF", shorttitle="CM_Ult_MacD_MTF") source = close useCurrentRes = input(true, title="Use Current Chart Resolution?") resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=resolution, defval="60") smd = input(true, title="Show MacD & Signal Line? Also Turn Off Dots Below") sd = input(true, title="Show Dots When MacD Crosses Signal Line?") sh = input(true, title="Show Histogram?") macd_colorChange = input(true,title="Change MacD Line Color-Signal Line Cross?") hist_colorChange = input(true,title="MacD Histogram 4 Colors?")
-
- Assistant