// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © djmad //@version=5 indicator(title='[MAD] Position starter & calculator', shorttitle='[MAD] Pos. S&C', overlay=true , max_boxes_count=500, max_lines_count=500, max_labels_count=500) // load Standardparts import djmad/Position_control/1 as POS_CON import djmad/Mad_Standardparts/1 as STDP // // Variables and definitios { var int colortheme = na var M_Colors = matrix.new(6, 10, na) var int bartime = na var POS_CON.t_Position_type[] myPosition = array.new() var POS_CON.t_drawing_parameters myParameters = na if bar_index == 200 bartime := STDP.f_getbartime() //} ///////////////////// INPUTS IN TYPES /////////////////// { if barstate.isfirst colortheme := input.int(5, "Colortheme",minval = 0, maxval = 5, group='Colortheme (0 = Darkmode, 1 = Lightmode', tooltip='0 Darkmode, 1 Lightmode, 2 @Wotan_BitBlockArt, 3 @Linden_Blues, 4 @BitcoinFranken87') var p_prolong_lines = input.bool(false,"Extend lines to the left", group='Colortheme (0 = Darkmode, 1 = Lightmode') var p_showPos = input.bool(false, "Show contracts", inline="AC3", group='Leverage/Capital'), var p_showLIQ = input.bool(false,"Show liquidation", group='Leverage/Capital') var float SET_SL_PRICE = input.price(defval=100, title= "SL", inline="XE1", confirm = true, group='SL') var float SET_SL_LOT = 100 var int SET_Starttime = input.time(timestamp("2020-02-19"),title= "Entry - Left limit", inline="EB1", confirm = true, group='Entrybox start'), var float SET_Entry_Start = input.price(defval=100, title= "Entry_Boxbegin", inline="EB1", confirm = true, group='Entrybox start'), var int SET_Stoptime = input.time(timestamp("2020-02-19"),title= "Entry - Right limit", inline="EB2", confirm = true, group='Entrybox stop'), var float SET_Entry_Stop = input.price(defval=100, title= "Entry_Boxstop", inline="EB2", confirm = true, group='Entrybox stop'), var float SET_Lot = input.float(1,"Contracts",minval = 0.000000000000000001, inline="AC3", group='Leverage/Capital'), var float SET_Leverage = input.float(20,"Leverage",minval = 1,maxval = 100,step=1, inline="LE1", group='Leverage/Capital'), var float SET_Maintenance = (100-input.float(50, "max. margin %", minval=0, maxval=100 , inline="LE1", group='Leverage/Capital',step = 1))/10000, var float SET_TP_PRICE_1 = input.price(defval=100.0, title= "TP_1", inline="PO1", confirm = true, group='Targets') var float SET_TP_PRICE_2 = input.price(defval=110.0, title= "TP_2", inline="PO2", confirm = true, group='Targets') var float SET_TP_PRICE_3 = input.price(defval=120.0, title= "TP_3", inline="PO3", confirm = true, group='Targets') var float SET_TP_PRICE_4 = input.price(defval=130.0, title= "TP_4", inline="PO4", confirm = true, group='Targets') var float SET_TP_PRICE_5 = input.price(defval=140.0, title= "TP_5", inline="PO5", confirm = true, group='Targets') var float SET_TP_LOT_1 = input.float(defval=20.0, title= "TP_1 %", inline="PO1", group='Targets')/100 var float SET_TP_LOT_2 = input.float(defval=20.0, title= "TP_2 %", inline="PO2", group='Targets')/100 var float SET_TP_LOT_3 = input.float(defval=20.0, title= "TP_3 %", inline="PO3", group='Targets')/100 var float SET_TP_LOT_4 = input.float(defval=20.0, title= "TP_4 %", inline="PO4", group='Targets')/100 var float SET_TP_LOT_5 = input.float(defval=20.0, title= "TP_5 %", inline="PO5", group='Targets')/100 var string pStr_fontsize = input.string(size.normal, title='Font-Size', options=[size.tiny, size.small, size.normal, size.large, size.huge], group='common') var int pTextshift = input.int(70,"Text shifting",minval = 0,maxval = 100, inline="PP1", group='common') var int pDecimals_price = input.int(2,"Decimals Price",minval = -3,maxval = 10, inline="PP1", group='common') var int pDecimals_contracts = input.int(2,"Decimals Contracts",minval = -3,maxval = 10, inline="PP2", group='common') var int pDecimals_percent = input.int(2,"Decimals Percent",minval = -3,maxval = 10, inline="PP2", group='common') //////////////////// Input and Switch of Colors /////////////////////// // } ///////////////////// INPUTS of colors /////////////////// { matrix.set(M_Colors,0,0, input.color(color.rgb(255, 153, 000, 40), title= "LIQ D-T", inline="Liquidation", group='Colors')) matrix.set(M_Colors,1,0, input.color(color.rgb(255, 153, 000, 40), title= "L-T", inline="Liquidation", group='Colors')) matrix.set(M_Colors,0,2, input.color(color.rgb(255, 082, 082, 40), title= " SL D-T", inline="Stoploss", group='Colors')) matrix.set(M_Colors,1,2, input.color(color.rgb(255, 082, 082, 40), title= "L-T", inline="Stoploss", group='Colors')) matrix.set(M_Colors,0,4, input.color(color.rgb(255, 255, 255, 60), title= " Box D-T", inline="Entrybox", group='Colors')) matrix.set(M_Colors,1,4, input.color(color.rgb(000, 000, 000, 60), title= "L-T", inline="Entrybox", group='Colors')) matrix.set(M_Colors,0,6, input.color(color.rgb(255, 255, 255, 40), title= " TP D-T", inline="TPs", group='Colors')) matrix.set(M_Colors,1,6, input.color(color.rgb(054, 058, 069, 40), title= "L-T", inline="TPs", group='Colors')) matrix.set(M_Colors,0,8, input.color(color.rgb(255, 255, 255, 33), title= " Text D-T", inline="Text", group='Colors')) matrix.set(M_Colors,1,8, input.color(color.rgb(000, 000, 000, 33), title= "L-T", inline="Text", group='Colors')) matrix.set(M_Colors,0,1, input.color(color.rgb(255, 153, 000, 40), title= "LIQ draftline D-T", inline="Liquidation-helper", group='Colors')) matrix.set(M_Colors,1,1, input.color(color.rgb(255, 153, 000, 40), title= "L-T", inline="Liquidation-helper", group='Colors')) matrix.set(M_Colors,0,3, input.color(color.rgb(255, 082, 082, 40), title= " SL draftline D-T", inline="Stoploss-helper", group='Colors')) matrix.set(M_Colors,1,3, input.color(color.rgb(255, 082, 082, 40), title= "L-T", inline="Stoploss-helper", group='Colors')) matrix.set(M_Colors,0,5, input.color(color.rgb(035, 116, 071, 40), title= " Box draftline D-T", inline="Entrybox-helper", group='Colors')) matrix.set(M_Colors,1,5, input.color(color.rgb(120, 134, 123, 40), title= "L-T", inline="Entrybox-helper", group='Colors')) matrix.set(M_Colors,0,7, input.color(color.rgb(255, 255, 255, 50), title= " TP draftline D-T", inline="TPs-helper", group='Colors')) matrix.set(M_Colors,1,7, input.color(color.rgb(054, 058, 069, 50), title= "L-T", inline="TPs-helper", group='Colors')) //color Wotan matrix.set(M_Colors,2,0, color.rgb(144, 026, 026, 00)) matrix.set(M_Colors,2,2, color.rgb(255, 120, 093, 40)) matrix.set(M_Colors,2,4, color.rgb(255, 161, 094, 72)) matrix.set(M_Colors,2,6, color.rgb(000, 151, 065, 40)) matrix.set(M_Colors,2,8, color.rgb(000, 192, 192, 00)) matrix.set(M_Colors,2,1, color.rgb(255, 179, 000, 60)) matrix.set(M_Colors,2,3, color.rgb(251, 075, 075, 60)) matrix.set(M_Colors,2,5, color.rgb(000, 086, 009, 60)) matrix.set(M_Colors,2,7, color.rgb(255, 255, 255, 50)) //color Lindener matrix.set(M_Colors,3,0, color.rgb(255, 136, 000, 00)) matrix.set(M_Colors,3,2, color.rgb(237, 047, 047, 40)) matrix.set(M_Colors,3,4, color.rgb(080, 183, 078, 50)) matrix.set(M_Colors,3,6, color.rgb(060, 065, 078, 33)) matrix.set(M_Colors,3,8, color.rgb(000, 000, 000, 00)) matrix.set(M_Colors,3,1, color.rgb(255, 179, 000, 40)) matrix.set(M_Colors,3,3, color.rgb(251, 075, 075, 40)) matrix.set(M_Colors,3,5, color.rgb(064, 149, 073, 13)) matrix.set(M_Colors,3,7, color.rgb(068, 071, 083, 50)) //color Matze matrix.set(M_Colors,4,0, color.rgb(190, 021, 021, 00)) matrix.set(M_Colors,4,2, color.rgb(234, 040, 040, 40)) matrix.set(M_Colors,4,4, color.rgb(018, 111, 205, 90)) matrix.set(M_Colors,4,6, color.rgb(000, 237, 103, 00)) matrix.set(M_Colors,4,8, color.rgb(255, 255, 255, 00)) matrix.set(M_Colors,4,1, color.rgb(255, 000, 166, 00)) matrix.set(M_Colors,4,3, color.rgb(255, 015, 015, 00)) matrix.set(M_Colors,4,5, color.rgb(064, 121, 255, 00)) matrix.set(M_Colors,4,7, color.rgb(255, 255, 255, 00)) //color Dark Light compatible matrix.set(M_Colors,5,0, color.rgb(144, 026, 026, 20)) matrix.set(M_Colors,5,2, color.rgb(255, 120, 093, 20)) matrix.set(M_Colors,5,4, color.rgb(255, 161, 094, 80)) matrix.set(M_Colors,5,6, color.rgb(000, 151, 065, 20)) matrix.set(M_Colors,5,8, color.rgb(000, 192, 192, 20)) matrix.set(M_Colors,5,1, color.rgb(255, 179, 000, 20)) matrix.set(M_Colors,5,3, color.rgb(251, 075, 075, 20)) matrix.set(M_Colors,5,5, color.rgb(000, 086, 009, 20)) matrix.set(M_Colors,5,7, color.rgb(180, 180, 180, 20)) //select colorset var A_Colors = matrix.row(M_Colors,colortheme) ///////////////////// } // fill a single position with manual Data from Inputs{ myParameters := POS_CON.t_drawing_parameters.new(ShowPos = p_showPos, ShowLIQ = p_showLIQ, A_Colors = A_Colors, Prolong_lines = p_prolong_lines, Str_fontsize = pStr_fontsize, Textshift = pTextshift, Decimals_contracts = pDecimals_contracts, Decimals_price = pDecimals_price, Decimals_percent = pDecimals_percent, bartime = bartime) var TP_Variant_type = POS_CON.t_TP_Variant.new(TP_Type = "Direct", TP_Parameter_1 = 0, TP_Parameter_2 = 0, TP_Parameter_3 = 0, TP_Parameter_4 = 0) var TPs_array1 = array.new(1, POS_CON.t_TPs.new(TP_Price = SET_TP_PRICE_1, TP_Lot = SET_TP_LOT_1, TP_Variant = TP_Variant_type, TP_Active = true)) var TPs_array2 = array.new(1, POS_CON.t_TPs.new(TP_Price = SET_TP_PRICE_2, TP_Lot = SET_TP_LOT_2, TP_Variant = TP_Variant_type, TP_Active = true)) var TPs_array3 = array.new(1, POS_CON.t_TPs.new(TP_Price = SET_TP_PRICE_3, TP_Lot = SET_TP_LOT_3, TP_Variant = TP_Variant_type, TP_Active = true)) var TPs_array4 = array.new(1, POS_CON.t_TPs.new(TP_Price = SET_TP_PRICE_4, TP_Lot = SET_TP_LOT_4, TP_Variant = TP_Variant_type, TP_Active = true)) var TPs_array5 = array.new(1, POS_CON.t_TPs.new(TP_Price = SET_TP_PRICE_5, TP_Lot = SET_TP_LOT_5, TP_Variant = TP_Variant_type, TP_Active = true)) var TPs_array_all = array.concat(TPs_array1,array.concat(TPs_array2,array.concat(TPs_array3,array.concat(TPs_array4,TPs_array5)))) var SLs_array1 = array.new(1,POS_CON.t_SLs.new(SL_Price = SET_SL_PRICE, SL_Lot = na, SL_Active = na)) var SLs_array_all = SLs_array1 myPosition.unshift( POS_CON.t_Position_type.new(Lot = SET_Lot, Leverage = SET_Leverage, Maintenance= SET_Maintenance, Starttime = SET_Starttime, Entry_Start = SET_Entry_Start, Stoptime = SET_Stoptime, Entry_Stop = SET_Entry_Stop, Entryprice = (SET_Entry_Start+SET_Entry_Stop)/2, TPs = TPs_array_all, SLs = SLs_array_all)) // } ///////////////////// FUNCTIONS //////////////////////// { // Runtime { STDP.clear_all() if (barstate.isrealtime or barstate.islast) and myPosition.size() > 0 POS_CON.f_drawposition(_Position = myPosition, _Parameters = myParameters , _Position_index = 0) // }